package com.plian.system.service.hr.recruitment.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.hr.recruitment.RecruitmentManagementChild;
import com.plian.system.mapper.hr.recruitment.RecruitmentManagementChildMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.hr.recruitment.IRecruitmentManagementChildService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 招聘管理子表 服务实现类
 *
 * @author gangan
 * @since 2019-11-15
 */
@Slf4j
@Service
@AllArgsConstructor
public class RecruitmentManagementChildServiceImpl extends BaseServiceImpl<RecruitmentManagementChildMapper, RecruitmentManagementChild> implements IRecruitmentManagementChildService {

    @Override
    public Boolean deleteLogicRecruitmentManagementId(List<Long> ids) {
        LambdaQueryWrapper<RecruitmentManagementChild> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(RecruitmentManagementChild::getRecruitmentManagementId, ids);
        List<RecruitmentManagementChild> recruitmentManagementChildList = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(recruitmentManagementChildList)){
            return deleteLogic(recruitmentManagementChildList.stream().map(RecruitmentManagementChild::getId).collect(Collectors.toList()));
        }
        return true;
    }
}
